package com.dreamchaser.book.entity;

/**
 * user用户
 * @author Dreamchaser
 */
public class User {
    private Integer id;
    private String uname;
    private String account;
    private String pwd;
    private Integer role;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUname() {
        return uname;
    }

    public void setUname(String uname) {
        this.uname = uname;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    public int getRole() {
        return role;
    }

    public void setRole(int role) {
        this.role = role;
    }

    /**
     * 获取User的查询条件
     * @return 字符串
     */
    public String getQueryCondition(){
        StringBuilder stringBuilder=new StringBuilder("1=1");
        if (id!=null){
            stringBuilder.append(" and id="+id);
        }
        if (uname!=null){
            stringBuilder.append(" and uname= '"+uname+"'");
        }
        if (account!=null){
            stringBuilder.append(" and account='"+account+"'");
        }
        if (pwd!=null){
            stringBuilder.append(" and pwd='"+pwd+"'");
        }
        if (role!=null){
            stringBuilder.append(" and role="+role);
        }
        return stringBuilder.toString();
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", uname='" + uname + '\'' +
                ", account='" + account + '\'' +
                ", pwd='" + pwd + '\'' +
                ", role=" + role +
                '}';
    }
}
